<?php
defined('_JEXEC') or die('Restricted access');
$tmpl = "templates/tpl_automobil/";
$db = JFactory::getDBO();
$sess = JFactory::getSession();
?>
<script type="text/javascript" src="<?php echo $tmpl;?>js/tooltips.js"></script>

<link rel="stylesheet" href="<?php echo $tmpl;?>css/jquery.ui.all.css"/>
<script src="<?php echo $tmpl;?>js/jquery.ui.core.js"></script>
<script src="<?php echo $tmpl;?>js/jquery.ui.widget.js"></script>
<script src="<?php echo $tmpl;?>js/jquery.ui.datepicker.js"></script>
<script type="text/javascript" src="<?php echo $tmpl;?>js/jquery.ui.datepicker-da.js"></script>
<script type="text/javascript" src="<?php echo $tmpl;?>js/jquery.maskedinput-1.2.2.js"></script>
<link rel="stylesheet" href="<?php echo $tmpl;?>css/datepicker.css"/>
<script>
$(function() {
	$( ".datepicker,.datepicker1" ).datepicker({
			changeMonth: true,
			changeYear: true
		});	
	
});
$(document).ready(function(){
	checkNum = function(){
		if($('#nejnum').is(':checked')){
			$('#carid').val('');
			$('#carid').attr('disabled','disabled');
		}
		if($('#janum').is(':checked')){
			$('#carid').removeAttr('disabled');
		}
	}
	
	if($('#nejnum').is(':checked')){
		$('#carid').val('');
		$('#carid').attr('disabled','disabled');
	}
	if($('#janum').is(':checked')){
		$('#carid').removeAttr('disabled');
	}
		
	submitCar = function(){
		document.getElementById('sendInformationCar').click();
	}
});
</script>
<script language="javascript">
jQuery(document).ready(function(cash) {
	jQuery("#placering").mask("9999",{placeholder:""});
  	jQuery("#infoCar").validate({
   		errorPlacement: function(error, element) {   
   		},
		invalidHandler: function(form, validator) {
			var errors = validator.numberOfInvalids();
			if (errors) {
				$('#alert').html(validator['errorList'][0]['message']);
				$('#backoverlay').show();
				$('#show_popup').show();
				$('#f_focus').html(validator['errorList'][0]['element'].name);
				validator['errorList'][0]['element'].focus();
			} else {
			}
   		},
   		rules: {
			placering: "required",
			model : "required",
			desired_price : "required",
			register_day : "required",
			view_day : "required",
			km : "required",
			chassis : "required"
   		},
   		messages: {
			placering: "Venligst den postnr.",
			model: "Venligst vælg mærke/model",
			desired_price: "Venligst oplys din forventet hammerslagspris",
			register_day: "Venligst oplys 1st reg. dato",
			view_day: "Venligst oplys seneste syn",
			km: "Venligst oplys Km.stand",
			chassis: "Venligst oplys stelnummer"
   		}
  	}); 
	   
});
</script>
<p><span class="float_left f28">Tilmelding af bil</span><span class="link-login"><a href="index.php?option=com_user&view=user&layout=profile&Itemid=13">
  <?php if($user->guest==0) {echo  "Min Profil";} ;?>
  </a><a href="index.php?option=com_user&view=login&task=logout&Itemid=13" class="m12l">
  <?php if($user->guest==0) {echo  "Log ud";};?>
  </a></span></p>
<div class="cb"></div>
<div class="tt m10b"></div>
<div class="box_gude p10l p30b">
    <div class="w720 form_tilmelding1 float_left">
    	<div class="status-step"></div>
    	<div class="form_tilmelding_other w462 float_left">
    		<h3 class="boder_b_d m10b">Tilmelding af bil</h3>
            <form name="infoCar" id="infoCar" method="post" enctype="multipart/form-data">
            <input type="submit" name="sendInformationCar" id="sendInformationCar" style="display:none" />
            <input type="hidden" name="option" value="com_ecommerce" />
            <input type="hidden" name="task" value="saveStep1" />
        
            <label style="width:190px;">Tilmelding af bilen Biltype:<span>*</span></label>
            <select style="text-align:center;width:206px;" class="w256" name="car_type">
                <option <?php if($sess->get('car_type') == 'Personbil') echo 'selected="selected"';?> value="Personbil">Personbil</option>
                <option <?php if($sess->get('car_type') == 'Varevogn momsfri') echo 'selected="selected"';?> value="Varevogn momsfri">Varevogn momsfri</option>
                <option <?php if($sess->get('car_type') == 'Varevogn + moms') echo 'selected="selected"';?> value="Varevogn + moms">Varevogn + moms</option>
            </select>
            <label style="width:190px;">Postnr. for placering af bilen:<span>*</span></label>
            <input name="placering" type="text" class="txt_tilmelding_other" id="placering" value="<?php echo $sess->get('placering');?>" style="width:200px;" />
            <label>Mærke/Model:<span>*</span></label>
            <input name="model" type="text" class="txt_tilmelding_other w390" id="model" value="<?php echo $sess->get('model');?>" />
            <label>Brændstof:<span>*</span></label>
            <select style="text-align:center;"  class="w256" name="fuel">
                <option <?php if($sess->get('fuel') == 'Benzin') echo 'selected="selected"';?> value="Benzin">Benzin</option>
                <option <?php if($sess->get('fuel') == 'Diesel') echo 'selected="selected"';?> value="Diesel">Diesel</option>
            </select>
            <label style="width:190px;">Din forventet hammerslagspris:<span>*</span></label>
            <input name="desired_price" type="text" class="txt_tilmelding" id="desired_price" style="width:170px; text-align:center;" value="<?php echo $sess->get('desired_price');?>" /> <span style="line-height:29px; color:#000">DKK</span>
     		
    		<label>1st Reg.:<span>*</span></label>
            <input id="register_day" name="register_day" type="text" class="txt_tilmelding_other w390 datepicker" value="<?php echo $sess->get('register_day');?>" style="background:url('<?php echo $tmpl;?>images/calendar.gif') right no-repeat; cursor:pointer;" />
            
            <label>Seneste syn:<span>*</span></label>
            <input id="view_day" name="view_day" type="text" class="txt_tilmelding_other w390 datepicker1" value="<?php echo $sess->get('view_day');?>" style="background:url('<?php echo $tmpl;?>images/calendar.gif') right no-repeat; cursor:pointer;" />
             <label>Skal synes:<span>*</span></label> 
             <select style="text-align:center;" name="registry">
                <option <?php if($sess->get('registry') == 'Ja') echo 'selected="selected"';?> value="Ja">Ja</option>
                <option <?php if($sess->get('registry') == 'Nej') echo 'selected="selected"';?> value="Nej">Nej</option>
            </select>
    		<div class="cl"></div>
            <label>Stand/Kategori:<span>*</span></label>
            <select style="text-align:center;" name="stand">
                <option <?php if($sess->get('stand') == 'A') echo 'selected="selected"';?> value="A">A</option>
            	<option <?php if($sess->get('stand') == 'B') echo 'selected="selected"';?> value="B">B</option>
            	<option <?php if($sess->get('stand') == 'UK') echo 'selected="selected"';?> value="UK">UK</option>
            </select>
            <div class="tooltip-eps" ><img src="<?php echo $tmpl;?>images/ico_info.png" alt="" /> 
                <div class="wrapper-tooltip">            
                    <div class="tooltip-top"></div>
                    <div class="tooltip-content">
                    	<?php 
							$db->setQuery("SELECT title, introtext FROM #__content WHERE id = 17");
							$stand_note = $db->loadObject();
							?>
                         <h6><?php echo $stand_note->title;?></h6>
                         <?php echo $stand_note->introtext;?>
                    </div>
                    <div class="tooltip-bottom"></div>
                </div>
			</div>
            <div class="cl"></div>
            <label>Km.stand:<span>*</span></label>
            <input name="km" type="text" class="txt_tilmelding_other" value="<?php echo $sess->get('km');?>" id="km" />
            <label>Stelnummer:<span>*</span></label>
            <input name="chassis" id="chassis" type="text" class="txt_tilmelding_other" value="<?php echo $sess->get('chassis');?>" />
            <label>Farve:</label>
            <input name="color" id="color" type="text" class="txt_tilmelding_other" value="<?php echo $sess->get('color');?>" />
			<!--<label>Lakstand:</label>
            <input name="color_type" id="color_type" type="text" class="txt_tilmelding_other" value="<?php echo $sess->get('color_type');?>" />
			<label>Kabinefarve:</label>
            <input name="cabin_color" id="cabin_color" type="text" class="txt_tilmelding_other" value="<?php echo $sess->get('cabin_color');?>" />-->
			
            <div class="cb"></div>
			<label>Har nummerplader:</label>
			<div class="m10t">
				<input <?php if($sess->get('carid')) echo 'checked="checked"';?> name="rdbHar" type="radio" value="Ja" id="janum" onchange="checkNum();"/><span class="pblack"> Ja &nbsp; &nbsp;</span>
	            <input <?php if(!$sess->get('carid')) echo 'checked="checked"';?> name="rdbHar" type="radio" value="Nej" id="nejnum" onchange="checkNum();"/><span class="pblack"> Nej</span>
			</div>
			<div class="cb"></div>
            <label>Registeringsnummer:</label>
            <input name="carid" id="carid" type="text" class="txt_tilmelding_other w390" value="<?php echo $sess->get('carid');?>"/>

            <div class="cb"></div>
              
    		<div class="m15t"></div>
            <?php if(JRequest::getVar('action') == 'edit'){?>
            <a href="javascript:void(0);" class="bt_save float_left btn" onclick="submitCar();"></a>
            <input type="hidden" name="action" value="edit" />
            <?php } else {?>
            <a href="javascript:void(0);" class="bt_next1 float_left" onclick="submitCar();"></a>
            <?php }?>
        </form>
    </div></div>
    <p class="cb"></p>
</div>